Match ‘a’ followed by 3 chars¶
pattern = ‘a{3}?’
Write a python program that matches a string
that has an a followed by three ‘b’.
import re
def text_match(S):
pattern = 'a{3}?'
if re.search(pattern, S):
return 'Found a match!'
else:
return('Not matched!')
# test
print(text_match("abbb")) # Found a match!
print(text_match("aabbbbbc")) # Found a match!